﻿using HR.Config;
using HR.Filters;
using HR.IService;
using HR.Models;
using Microsoft.AspNetCore.Mvc;

namespace HR.Controllers
{
    public class PublicPropSetController : Controller
    {
        private readonly IPublicConfigService ipcs;

        public PublicPropSetController(IPublicConfigService ipcs)
        {
            this.ipcs = ipcs;
        }
        [TypeFilter(typeof(RoleFilterAttribute))]
        public IActionResult PublicPropConfig()
        {
            return View();
        }
        [HttpGet]
        public async Task<IActionResult> PublicPropFill(int pgsize,int pgcurrent)
        {
            Paging<config_public_char> pg = await ipcs.PublicConfigFill(pgsize,pgcurrent);
            return Json(pg);
        }
        [HttpPost]
        public async Task<IActionResult> PublicPropAdd([FromBody] config_public_char cpc)
        {
            int res = await ipcs.PublicConfigAdd(cpc);
            return Json(res);
        }
        [HttpPost]
        public async Task<IActionResult> PublicPropUpdate([FromBody] config_public_char cpc)
        {
            int res = await ipcs.PublicConfigUpdate(cpc);
            return Json(res);
        }
        [HttpDelete]
        public async Task<IActionResult> PublicPropDelete(short pbc_id)
        {
            int res = await ipcs.PublicConfigDelete(pbc_id);
            return Json(res);
        }
    }
}
